package o;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import com.huawei.appmarket.R;
import java.lang.ref.WeakReference;
import BaseDialog.a;

class dzp {
    private static dzp ˎ = new dzp();
    private boolean ˊ;
    private WeakReference<BaseAlertDialog> ˏ = null;
    private boolean ॱ = false;

    private dzp() {
    }

    public static dzp ˏ() {
        return ˎ;
    }

    public boolean ˎ() {
        return this.ॱ;
    }

    public void ˏ(boolean z) {
        this.ॱ = z;
    }

    public void ˎ(Activity activity, final Runnable runnable, final Runnable runnable2) {
        if (!ActivityUtil.isAcitivtyNotValid(activity)) {
            BaseAlertDialog o_ckr;
            if (this.ˏ != null) {
                o_ckr = (BaseAlertDialog) this.ˏ.get();
            } else {
                o_ckr = null;
            }
            if (o_ckr == null || !o_ckr.ˎ()) {
                o_ckr = BaseAlertDialog.ˋ(activity, null, activity.getResources().getString(R.string.login_failed_prompt));
                this.ˏ = new WeakReference(o_ckr);
                this.ˊ = false;
                o_ckr.ॱ();
                o_ckr.ˎ(new cks(this) {
                    final /* synthetic */ dzp ˎ;

                    public void enableNetworking() {
                        this.ˎ.ˊ = true;
                        runnable.run();
                    }

                    public void upgrade() {
                        runnable2.run();
                    }

                    public void ˋ() {
                    }
                });
                o_ckr.ˎ(new OnDismissListener(this) {
                    final /* synthetic */ dzp ˎ;

                    public void onDismiss(DialogInterface dialogInterface) {
                        if (!this.ˎ.ˊ) {
                            runnable2.run();
                        }
                    }
                });
                o_ckr.ॱ(a.CONFIRM, activity.getResources().getString(R.string.get_userinfo_retry));
            }
        }
    }
}
